home *** CD-ROM | disk | FTP | other *** search
/ APDL Eductation Resources / APDL Eductation Resources.iso / programs / electronic / rlab / TestMatrix / circul_r < prev    next >
Encoding:
Text File  |  1994-12-20  |  1.3 KB  |  52 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. // Synopsis:    Circulant matrix.
  4.  
  5. // Syntax:    C = circul ( V )
  6.  
  7. // Description:
  8.  
  9. //    C is the circulant matrix whose first row is V. A circulant
  10. //    matrix has the property that each row is obtained from the
  11. //    previous one by cyclically permuting the entries one step
  12. //    forward; it is a special Toeplitz matrix in which the
  13. //    diagonals `wrap round'.)
  14.  
  15. //    Special case: if V is a scalar then C = circul(1:V).
  16.  
  17. //    The eigensystem of C (N-by-N) is known explicitly.   If t is
  18. //    an Nth root of unity, then the inner product of V with 
  19. //    W = [1, t, t^2, ... t^N] is an eigenvalue of C, and W[N:1:-1]
  20. //    is an eigenvector of C. 
  21.  
  22. //      Reference:
  23. //        P.J. Davis, Circulant Matrices, John Wiley, 1977.
  24.  
  25. //    This file is a translation of circul.m from version 2.0 of
  26. //    "The Test Matrix Toolbox for Matlab", described in Numerical
  27. //    Analysis Report No. 237, December 1993, by N. J. Higham.
  28.  
  29. // Dependencies
  30.    require toeplitz
  31.  
  32. //-------------------------------------------------------------------//
  33.  
  34. circul = function ( v )
  35. {
  36.   local (v)
  37.  
  38.    n = max(size(v));
  39.  
  40.   if (n == 1)
  41.   {
  42.     n = v;
  43.     v = 1:n;
  44.   }
  45.  
  46.   v = v[:].';    // Make sure v is a row vector.
  47.  
  48.   C = toeplitz( [ v[1], v[n:2:-1] ], v );
  49.  
  50.   return C;
  51. };
  52.